package com.xinfu.newproject.ui.matter_repair.matter_repair_child;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alley.van.VanGogh;
import com.alley.van.helper.VanCropType;
import com.alley.van.helper.VanMediaFilter;
import com.alley.van.helper.VanMediaType;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.Gson;
import com.xinfu.newproject.R;
import com.xinfu.newproject.activity.ResidentCertificationActivity;
import com.xinfu.newproject.adapter.matter_repair_adapter.RepairImageAdapter;
import com.xinfu.newproject.adapter.matter_repair_adapter.RepairPartsAdapter;
import com.xinfu.newproject.base.BaseActivity;
import com.xinfu.newproject.bean.certifition.QeuryRoomBean;
import com.xinfu.newproject.bean.certifition.ResidentBean;
import com.xinfu.newproject.bean.certifition.ResidentCertificationBean;
import com.xinfu.newproject.bean.login.LoginBean;
import com.xinfu.newproject.bean.matter_repair.AddRepairBean;
import com.xinfu.newproject.bean.matter_repair.QueryRepairPartsBean;
import com.xinfu.newproject.bean.matter_repair.RepairDetailBean;
import com.xinfu.newproject.bean.matter_repair.RepairRecordBean;
import com.xinfu.newproject.bean.matter_repair.bean.RepairCountBean;
import com.xinfu.newproject.bean.matter_repair.bean.RepairEvaluateBean;
import com.xinfu.newproject.bean.up_image.UpImageBean;
import com.xinfu.newproject.contants.Contants;
import com.xinfu.newproject.interface_.SwichFragmentInterface;
import com.xinfu.newproject.presenter.AddRepairPresenter;
import com.xinfu.newproject.presenter.QeuryRoomPresenter;
import com.xinfu.newproject.presenter.QueryRepairPartsPresenter;
import com.xinfu.newproject.presenter.RepairRecordPresenter;
import com.xinfu.newproject.presenter.UpImagePresenter;
import com.xinfu.newproject.test.GifSizeFilter;
import com.xinfu.newproject.test.GlideImageLoader;
import com.xinfu.newproject.test.VanToast;
import com.xinfu.newproject.ui.matter_repair.RepairPartsFragment;
import com.xinfu.newproject.util.BToast;
import com.xinfu.newproject.util.DateFormatUtils;
import com.xinfu.newproject.util.GetImagePathUtil;
import com.xinfu.newproject.util.SPUtils;
import com.xinfu.newproject.util.WHelperUtil;
import com.xinfu.newproject.view.IView;
import com.xinfu.newproject.widget.CustomClickListener;
import com.xinfu.newproject.widget.picker_view.TimePickerView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.disposables.Disposable;

import static com.xinfu.newproject.contants.Constant.LOGIN;
import static com.xinfu.newproject.contants.Contants.REQUEST_CODE_AVATAR;
import static com.xinfu.newproject.contants.Contants.REQUEST_CODE_IMAGE;

public class TheRepairFragment extends BaseActivity implements IView.IQueryRepairPartsView, IView.ISubmitRepairView, IView.IQueryRoomView, IView.IUpImageView, RepairImageAdapter.RemoveOnClickListener, IView.IRepairRecordView {

    @BindView(R.id.head_right_text)
    TextView titleRightTv;

    @BindView(R.id.head_right_iv)
    ImageView rightRedIv;

    @BindView(R.id.head_back)
    ImageView backIv;

    @BindView(R.id.layout_choose_type_rv)
    RecyclerView mRecyclerView;

    @BindView(R.id.activity_the_repair_content_et)
    EditText contentEt;

    @BindView(R.id.layout_choose_person_info_name_et)
    EditText nameEt;

    @BindView(R.id.layout_choose_person_info_phone_et)
    EditText phoneEt;

    @BindView(R.id.layout_next_step_tv)
    TextView nextTv;

    @BindView(R.id.layout_choose_person_info_id)
    TextView room;

    @BindView(R.id.layout_choose_person_info_time)
    TextView appointTimeTv;

    @BindView(R.id.activity_the_repair_person)
    TextView peronTv;

    @BindView(R.id.activity_the_repair_public)
    TextView publicTv;

    @BindView(R.id.layout_up_image_rv)
    RecyclerView imageRecyclerView;

    private RepairImageAdapter repairImageAdapter;
    private static final int REQUEST_CODE_CHOOSE = 23;

    private int isImage = 0;
    private ArrayList<String> imageList = new ArrayList<>();

    private RepairPartsAdapter repairPartsAdapter;

    private SwichFragmentInterface swichFragmentInterface;

    private QueryRepairPartsPresenter queryRepairPartsPresenter = new QueryRepairPartsPresenter(this);
    private AddRepairPresenter addRepairPresenter = new AddRepairPresenter(this);
    private QeuryRoomPresenter qeuryRoomPresenter = new QeuryRoomPresenter(this);
    private UpImagePresenter upImagePresenter = new UpImagePresenter(this);
    private RepairRecordPresenter repairRecordPresenter = new RepairRecordPresenter(this);

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_the_repair);
        ButterKnife.bind(this);
        registerBack();
        setActivityTitle("我要报修");
        initViewBind();
        initLisener();
    }

    private void initLisener() {
        LoginBean.ResultBean resultBean;
        String responseIntent = (String) SPUtils.get(this, LOGIN, "0");
        if (!responseIntent.equals("0")) {
            resultBean = new Gson().fromJson(responseIntent, LoginBean.ResultBean.class);
            nameEt.setText(resultBean.getUserInfo().getUsername());
            phoneEt.setText(resultBean.getUserInfo().getPhone());
        }
        contentEt.setFilters(new InputFilter[]{inputFilter});

        nextTv.setOnClickListener(new CustomClickListener() {
            @Override
            protected void onSingleClick() {
                int isOk = isLogin(1);
                if (isOk == 1) {
                    showLoding();
                    if (imageList.size() > 0) {
                        if (isImage == 1) {
                            upImagePresenter.upImage();
                        } else {
                            BToast.showText(TheRepairFragment.this, "请上传图片");
                        }
                    } else {
                        BToast.showText(TheRepairFragment.this, "请上传图片");
                    }
                }
            }

            @Override
            protected void onFastClick() {

            }
        });
    }

    InputFilter inputFilter = new InputFilter() {
        Pattern emoji = Pattern.compile("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]",
                Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);

        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            Matcher emojiMatcher = emoji.matcher(source);
            if (emojiMatcher.find()) {
                BToast.showText(TheRepairFragment.this, "暂不支持输入表情");
                return "";
            }
            return null;
        }
    };

    private void initViewBind() {
        nextTv.setText("提交");
        titleRightTv.setText("记录");
        titleRightTv.setVisibility(View.VISIBLE);
        mRecyclerView.setLayoutManager(new GridLayoutManager(this, 4));
        repairPartsAdapter = new RepairPartsAdapter();
        repairPartsAdapter.openLoadAnimation();
        mRecyclerView.setAdapter(repairPartsAdapter);
        repairPartsAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                queryRepairPartsBean.getResult().get(position).setCheck(true);
                for (int i = 0; i < queryRepairPartsBean.getResult().size(); i++) {
                    if (i != position) {
                        queryRepairPartsBean.getResult().get(i).setCheck(false);
                    }
                }
                repairPartsAdapter.setNewData(queryRepairPartsBean.getResult());

                repairPartId = queryRepairPartsBean.getResult().get(position).getId();
            }
        });

        imageRecyclerView.setLayoutManager(new GridLayoutManager(this, 4));
        repairImageAdapter = new RepairImageAdapter(this);
        imageRecyclerView.setAdapter(repairImageAdapter);
        imageList.add(0, "0");
        repairImageAdapter.setNewData(imageList);
        repairImageAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @SuppressLint("CheckResult")
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                if (imageList.get(position).equals("0")) {
                    isCode = REQUEST_CODE_AVATAR;
                    onClickCamera();
                } else {
                    isCode = REQUEST_CODE_IMAGE;
                    imagePosition = position;
                    onClickCamera();
                }
            }
        });
    }

    int isCode;

    @Override
    public void permissionGrant(boolean isGranted, int requestCode) {
        super.permissionGrant(isGranted, requestCode);
        if (!isGranted) {
            return;
        }
        switch (requestCode) {

            case 0x0002://从相册选择
                int maxCount;
                if (isCode == REQUEST_CODE_AVATAR) {
                    maxCount = 5 - imageList.size();
                } else {
                    maxCount = 4;
                }
                VanGogh.from(TheRepairFragment.this)
                        .choose(VanMediaType.ofAll())
                        .countable(true)//若开启裁剪，则无效
                        .maxCount(maxCount)
                        .rowCount(3)
                        .cameraVisible(true, getPackageName())//设置在第一个参数为FALSE时，第二个参数无效
                        .withResultSize(1024, 1024)
                        .cropEnable(false, VanCropType.CROP_TYPE_RECTANGLE)//第一个参数为TRUE时，则可选中数量被设为1，此时maxSelectable(9)无效；第一个参数为FALSE时，第二个参数无效
                        .theme(R.style.VanTheme_Dracula)
                        .addFilter(new GifSizeFilter(320, 320, 5 * VanMediaFilter.K * VanMediaFilter.K))
                        .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
                        .thumbnailScale(0.85f)
                        .toast(new VanToast())
                        .imageLoader(new GlideImageLoader())
                        .forResult(REQUEST_CODE_CHOOSE);
                break;

            default:
                break;
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (isLogin()) {
            repairRecordPresenter.repairCount();
        }
        queryRepairPartsPresenter.queryRepair();
    }


    @OnClick({R.id.layout_choose_person_info_id, R.id.layout_choose_person_info_time, R.id.activity_the_repair_person, R.id.activity_the_repair_public, R.id.head_right_text})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.activity_the_repair_person:

                peronTv.setTextColor(getResources().getColor(R.color.yellow_ff));
                peronTv.setBackgroundResource(R.drawable.no_bg_text);
                publicTv.setTextColor(getResources().getColor(R.color.gray_9));
                publicTv.setBackgroundResource(R.drawable.no_bg_text_normal);
                appointTimeTv.setVisibility(View.VISIBLE);
                if (repairArea == 1) {
                    appointTimeTv.setText("请选择预约上门时间");
                    room.setText("请选择户号");
                    nameEt.getText().clear();
                    phoneEt.getText().clear();
                    contentEt.getText().clear();
                    imageList.clear();
                    imageList.add("0");
                    repairImageAdapter.setNewData(imageList);

                    strAppointment = null;
                    roomId = null;
                    residentBean = null;
                    isImage = 0;
                }
                repairArea = 0;
                break;
            case R.id.activity_the_repair_public:
                publicTv.setTextColor(getResources().getColor(R.color.yellow_ff));
                publicTv.setBackgroundResource(R.drawable.no_bg_text);
                peronTv.setTextColor(getResources().getColor(R.color.gray_9));
                peronTv.setBackgroundResource(R.drawable.no_bg_text_normal);
                appointTimeTv.setVisibility(View.GONE);
                if (repairArea == 0) {
                    appointTimeTv.setText("请选择预约上门时间");
                    room.setText("请选择户号");
                    nameEt.getText().clear();
                    phoneEt.getText().clear();
                    contentEt.getText().clear();
                    imageList.clear();
                    imageList.add("0");
                    repairImageAdapter.setNewData(imageList);

                    strAppointment = null;
                    roomId = null;
                    residentBean = null;
                    isImage = 0;
                }
                repairArea = 1;
                break;
            case R.id.layout_choose_person_info_id://选择房间
                Bundle bundle = new Bundle();
                bundle.putInt("type", Contants.CHOOSECOMMUNITYCERTIFITION);
                if (repairPartId != null) {
                    bundle.putString("partType", repairPartId);
                } else {
                    bundle.putString("partType", "-1");
                }
                startActivityForResult(new Intent(this, ResidentCertificationActivity.class).putExtras(bundle), Contants.CHOOSECOMMUNITYCERTIFITION);
                break;
            case R.id.layout_choose_person_info_time://选择预约时间
                appointment();
                break;
            case R.id.head_right_text:
                startIntentActivity(RepairPartsFragment.class, null);
                break;
        }
    }

    ResidentBean residentBean;
    String intentPartId;
    Integer imagePosition;

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK) {
            final ArrayList<String> pathList = new ArrayList<>();

            switch (requestCode) {
                case Contants.CHOOSECOMMUNITYCERTIFITION:
                    if (data.getExtras().getString("community") != null) {
                        residentBean = new Gson().fromJson(data.getExtras().getString("community"), ResidentBean.class);
                        ResidentCertificationBean.ResultBean.RoomCheckUserListBean video = (ResidentCertificationBean.ResultBean.RoomCheckUserListBean) residentBean.t;
                        roomId = video.getRoomId();
                        room.setText(data.getExtras().getString("title") + "\n" + video.getAddress());
                        String partId = data.getExtras().getString("partType");
                        if (partId.equals("-1")) {
                            repairPartId = null;
                        } else {
                            intentPartId = partId;
                        }
                    }
                    break;
                case REQUEST_CODE_CHOOSE:
                    if (VanGogh.obtainResult(data) != null) {
                        if (VanGogh.obtainResult(data).size() > 0) {
                            for (int i = 0; i < VanGogh.obtainResult(data).size(); i++) {
                                pathList.add(GetImagePathUtil.getRealFilePath(this, VanGogh.obtainResult(data).get(i)));
                            }
                        }
                    }
                    if (isCode == REQUEST_CODE_AVATAR) {
                        if ((imageList.size() - 1) < pathList.size()) {
                            if (imageList.size() == 1) {
                                imageList.clear();
                            } else {
                                imageList.remove(imageList.size() - 1);
                            }
                            for (int i = 0; i < pathList.size(); i++) {
                                imageList.add(i, pathList.get(i));
                            }
                        } else if ((5 - imageList.size()) >= pathList.size()) {
                            if (imageList.size() == 1) {
                                imageList.clear();
                            } else {
                                imageList.remove(imageList.size() - 1);
                            }
                            for (int i = 0; i < pathList.size(); i++) {
                                imageList.add(pathList.get(i));
                            }
                        }
                        isImage = 1;
                    } else {
                        if (pathList != null) {
                            if (pathList.size() > 0) {
                                if (pathList.size() == 1 && !pathList.get(0).equals("")) {
                                    if (imagePosition != null) {
                                        imageList.set(imagePosition, pathList.get(0));
                                    }
                                } else {
                                    if (!pathList.get(0).equals("")) {
                                        imageList.clear();
                                        for (int i = 0; i < pathList.size(); i++) {
                                            imageList.add(i, pathList.get(i));
                                        }
                                    }
                                }
                            }
                        }
                        imagePosition = null;
                        isImage = 1;
                    }
                    break;
            }
            for (int i = 0; i < imageList.size(); i++) {
                if (imageList.get(i).equals("0")) {
                    imageList.remove(i);
                }
            }
            if (imageList.size() < 4) {
                imageList.add("0");
            }
            repairImageAdapter.setNewData(imageList);
        }
    }

    int repairArea = 0;

    private void appointment() {
        final TimePickerView pvTime = new TimePickerView(this, TimePickerView.Type.ALL);
        pvTime.setTime(new Date());
        pvTime.setCyclic(false);
        pvTime.setCancelable(true);
        //时间选择后回调
        pvTime.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {

                if (date.getTime() + 58000 < System.currentTimeMillis()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(TheRepairFragment.this);
                    builder.setTitle("提示：");
                    builder.setMessage("您选择的时间小于当前时间，请重新选择！");
                    builder.setPositiveButton("好", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int poi) {
                            dialogInterface.dismiss();
                        }
                    });
                    builder.show();
                } else {
                    appointTimeTv.setText(DateFormatUtils.getTimeString(date));
                    strAppointment = DateFormatUtils.getTimeString(date);
                }

            }
        });
        pvTime.show();

    }

    //    @Override
//    public void onHiddenChanged(boolean hidden) {
//        super.onHiddenChanged(hidden);
//        if (!hidden) {
//            appointTimeTv.setText("请选择预约上门时间");
//            room.setText("请选择户号");
//            nameEt.getText().clear();
//            phoneEt.getText().clear();
//            contentEt.getText().clear();
//            imageList.clear();
//            imageList.add("0");
//            repairImageAdapter.setNewData(imageList);
//
//            strAppointment = null;
//            roomId = null;
//            residentBean = null;
//        }
//    }
    private boolean isLogin() {

        LoginBean.ResultBean resultBean;
        String responseIntent = (String) SPUtils.get(this, LOGIN, "0");
        if (!responseIntent.equals("0")) {
            resultBean = new Gson().fromJson(responseIntent, LoginBean.ResultBean.class);
            token = resultBean.getToken();
            userId = resultBean.getUserInfo().getId();
            userName = resultBean.getUserInfo().getUsername();
        } else {
            BToast.showText(this, "请先登录");
            return false;
        }

        return true;
    }

    /**
     * 判断是否可以请求数据
     */
    String token, userId, userName, projectId, strAppointment, repairPartId;
    int tenandId;

    private Integer isLogin(int type) {

        LoginBean.ResultBean resultBean;
        String responseIntent = (String) SPUtils.get(this, LOGIN, "0");
        if (!responseIntent.equals("0")) {
            resultBean = new Gson().fromJson(responseIntent, LoginBean.ResultBean.class);
            token = resultBean.getToken();
            userId = resultBean.getUserInfo().getId();
            userName = resultBean.getUserInfo().getUsername();
        } else {
            BToast.showText(this, "未登录");
            return 0;
        }
        if (type == 1) {
            if (TextUtils.isEmpty(contentEt.getText().toString())) {
                BToast.showText(this, "请填写完整信息");
                return 0;
            }
            if (contentEt.getText().toString().trim().equals("")) {
                BToast.showText(this, "请填写完整信息");
                return 0;
            }
            if (TextUtils.isEmpty(nameEt.getText().toString())) {
                BToast.showText(this, "请填写完整信息");
                return 0;
            }
            if (TextUtils.isEmpty(phoneEt.getText().toString())) {
                BToast.showText(this, "请填写完整信息");
                return 0;
            } else {
                if (!WHelperUtil.isMobileRight(this, phoneEt.getText().toString())) {
                    BToast.showText(this, "请填写正确的手机号");
                    return 0;
                }
            }
            if (strAppointment == null) {
                if (repairArea == 0) {
                    BToast.showText(this, "请填写完整信息");
                    return 0;
                }
            }

        }

        if (residentBean == null) {
            BToast.showText(this, "请填写完整信息");
            return 0;
        }
        if (responseIntent == null) {
            BToast.showText(this, "请填写完整信息");
            return 0;
        }
        if (residentBean == null) {
            BToast.showText(this, "请填写完整信息");
            return 0;
        }
        ResidentCertificationBean.ResultBean.RoomCheckUserListBean video = (ResidentCertificationBean.ResultBean.RoomCheckUserListBean) residentBean.t;
        projectId = video.getProjectId();
        tenandId = video.getTenantId();
        if (projectId == null) {
            BToast.showText(this, "请填写完整信息");
            return 0;
        }
//        Log.i("testProjectId", projectId);
        return 1;
    }

    @Override
    public String header() {
        return token;
    }

    @Override
    public List<String> imageList() {
        return imageList;
    }

    @Override
    public Context context() {
        return this;
    }

    @Override
    public String userId() {
        return userId;
    }

    @Override
    public String userName() {
        return nameEt.getText().toString().trim();
    }

    @Override
    public String contents() {
        return contentEt.getText().toString().trim();
    }

    @Override
    public String mobile() {
        return phoneEt.getText().toString().trim();
    }

    @Override
    public String repairDate() {
        return strAppointment;
    }

    @Override
    public String attachFile() {
        return attachFile;
    }

    @Override
    public String repairPartId() {
        return repairPartId;
    }

    @Override
    public int repairWay() {
        return 0;
    }

    @Override
    public String repairId() {
        return "";
    }

    @Override
    public String reviewContent() {
        return "";
    }

    @Override
    public String bespeakFromTime() {
        return strAppointment;
    }

    @Override
    public String bespeakToTime() {
        return strAppointment;
    }

    @Override
    public int tenantId() {
        return tenandId;
    }

    @Override
    public String projectId() {
        return projectId;
    }

    @Override
    public String roomId() {
        return roomId;
    }

    @Override
    public int repairArea() {
        return repairArea;
    }

    @Override
    public void showToast(String content) {
        BToast.showText(this, content);
    }

    @Override
    public void closeDispose(Disposable disposable) {

    }

    @Override
    public void getData(RepairRecordBean repairRecordBean) {

    }

    @Override
    public void getData(RepairDetailBean repairDetailBean) {

    }

    @Override
    public void getData(RepairCountBean repairCountBean) {
        if (repairCountBean.getResult() != null) {
            if (repairCountBean.getResult() > 0) {
                rightRedIv.setVisibility(View.VISIBLE);
            } else {
                rightRedIv.setVisibility(View.GONE);
            }
        } else {
            rightRedIv.setVisibility(View.GONE);
        }
    }

    String attachFile;

    @Override
    public void getData(UpImageBean upImageBean) {
        attachFile = upImageBean.getResult();
        Log.i("testImage", isImage + "");
        if (attachFile != null) {
            if (isImage == 1) {
                addRepairPresenter.submitRepair();
            } else {
                BToast.showText(this, "请上传图片");
            }
        }
    }

    @Override
    public void getData(QeuryRoomBean qeuryRoomBean) {

    }

    @Override
    public void getData(AddRepairBean addRepairBean) {
        hideLoding();
        BToast.showText(this, addRepairBean.getMessage());
        appointTimeTv.setText("请选择预约上门时间");
        room.setText("请选择户号");
        nameEt.getText().clear();
        phoneEt.getText().clear();
        contentEt.getText().clear();
        imageList.clear();
        imageList.add("0");
        repairImageAdapter.setNewData(imageList);

        strAppointment = null;
        roomId = null;
        residentBean = null;
        isImage = 0;
        startIntentActivity(RepairPartsFragment.class, null);
    }

    @Override
    public void getData(RepairEvaluateBean repairEvaluateBean) {

    }

    QueryRepairPartsBean queryRepairPartsBean;

    @Override
    public void getData(QueryRepairPartsBean queryRepairPartsBean) {
        this.queryRepairPartsBean = queryRepairPartsBean;
        if (intentPartId != null) {
            for (int i = 0; i < queryRepairPartsBean.getResult().size(); i++) {
                if (queryRepairPartsBean.getResult().get(i).getId().equals(intentPartId)) {
                    queryRepairPartsBean.getResult().get(i).setCheck(true);
                }
            }
            repairPartsAdapter.setNewData(queryRepairPartsBean.getResult());
            repairPartId = intentPartId;
        } else {
            queryRepairPartsBean.getResult().get(0).setCheck(true);
            repairPartsAdapter.setNewData(queryRepairPartsBean.getResult());
            repairPartId = queryRepairPartsBean.getResult().get(0).getId();
        }
    }

    /**
     * 选择房产
     *
     * @param options1Items
     * @param options2Items
     */
    String roomId;


    @Override
    public void removeImage(int position) {
        imageList.remove(position);
        for (int i = 0; i < imageList.size(); i++) {
            if (imageList.get(i).equals("0")) {
                imageList.remove(i);
            }
        }
        if (imageList.size() < 4) {
            imageList.add("0");
        }
        repairImageAdapter.setNewData(imageList);

    }
}
